package net.mcreator.mcreatordetector.procedures;

import net.neoforged.fml.ModList;

public class GetModInfoProcedure {
	public static String execute(String ModID) {
		var m = ModList.get().getModFileById(ModID);
		if(m == null){return "";}
		var sb = new StringBuilder();
		var d = m.getMods();
		if(d.isEmpty()){return "";}
		var i = d.getFirst();
		sb.append(i.getModId());
		sb.append("\n");
		sb.append(i.getNamespace());
		sb.append("\n");
		sb.append(i.getConfig().getConfigElement("displayURL").orElse(""));
		sb.append("\n");
		sb.append(i.getConfig().getConfigElement("credits").orElse(""));
		sb.append("\n");
		sb.append(i.getConfig().getConfigElement("displayName").orElse(""));
		sb.append("\n");
		sb.append(i.getConfig().getConfigElement("authors").orElse(""));
		sb.append("\n");
		return sb.toString().toLowerCase();
	}
}